Image Maps

Windows httpd 1.4 contains a new imagemapper program that uses the Windows CGI interface, and Windows' intrinsic graphics APIs to perform the hit tests. It also supports the "ellipse" region, which you should use if you can. The "circle" shape is still supported so you can use imagemap editors designed for other servers (see below).

If you want to make your life a lot easier, get a copy of Tom Boutell's MapEdit program. It allows you to lay out the imagemap hotspots with the mapped image in the background. I try to keep the latest version on the Windows httpd home page.


Introduction

The imagemap program reads the coordinates sent by the browser when the user clicks on an ISMAP image, and returns a URL reference for a document that depends on the click location. Since it is a native Windows application (and doesn't need a DOS VM) it runs quite fast.

The Central Configuration File

The imagemap script expects to find its configuration file as:

c:\httpd\conf\imagemap.cnf.

If you would like to change the location of this file, set up an environment variable called HTTPD_CONFDIR and set it to the path where imagemap.cnf willl be located.

In this file, lines beginning with a # are comments. Every other non-blank line consists of:

name : path

name is the name of the particular mapping. You use it when you reference the image.

path is the full path to the map configuration file for this mapping.


The Map Configuration File

This file maps regions to URLs for the given image.

Lines beginning with # are comments. Every other non-blank line consists of the following:

method url coord1 coord2 ... coordn
coord are each coordinates, format x,y. The number depends on method.

method is one of the following:

url is one of the following: Note: each method is evaluated in the order it is placed in the configuration file. If you have overlapping areas, such as a circle inside of a rectangle, you should place whichever one you want evaluated first before the other in the map file. In this case, we would put the circle before the rectangle.


Referencing Your New Map

To reference your new map, you construct URLs pointing to it.

For example, if you have a WinScriptAlias /cgi-win/ c:/httpd/cgi-win/, named your map fish, and used the image fish33.gif for the map, the following line of HTML will reference it:

<A HREF="/cgi-win/imagemap/fish"><IMG SRC="fish33.gif" ISMAP></A>


A Complete Example

The imagemap demonstration uses the following configuration files:

Central Configuration File

imapdemo : c:\httpd\conf\maps\imapdemo.map

Map Configuration File

The map configuration file for the demo is shown below. You can use Paintbrush or any other application that display the mouse coordinates by pixels to find locations.
# Demo map file
# This file should be pointed at by an entry in IMAGEMAP.CNF
#

#The default page is loaded if no other entries are hit.
default /demo/noshape.htm

# Circles are defined by two points; the first is the center, and the second
# is a point on the perimeter.
circle /demo/circle.htm 50,50 50,10

# Rects are defined by two diagonally opposite vertices.
rect /demo/rect.htm 130,10 170,90

# Polys can have any number of vertices. 
poly /demo/poly.htm 250,10 210,90 290,90
Return to administration overview


Robert B. Denny <rdenny@netcom.com>